#ifndef CONNECTION_H
#define CONNECTION_H
#include "qmessagebox.h"
#include <QtSql>
#include "qsqldatabase.h"
#include "qsqlquerymodel.h"
static bool createConnection()
{
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLDRIVER", "mysql_connection_string");
    QSqlDatabase::drivers();
    db.setHostName("localhost");
    db.setDatabaseName("test");
    db.setUserName("root");
    db.setPassword("123456");
    if (!db.open())
    {
        QMessageBox::critical(0,QObject::tr("Database Error"),db.lastError().text());
        return false;
    }
    else
        return true;
}

#endif // CONNECTION_H
